package lrz.shiftplanner.application;

import java.awt.Dimension;
import java.awt.GridBagLayout;
import java.awt.GridLayout;
import java.awt.Insets;
import java.util.List;

import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JPanel;
import javax.swing.border.EtchedBorder;


import lrz.shiftplanner.components.AdaptFontFactory;
import lrz.shiftplanner.components.Selector;

import com.sun.awt.AWTUtilities;





public class SelectorWindow extends JFrame {
	private JPanel mainPanel;
	private Selector selector;
	
	private int gx;
	private int gy;
	
	public void alignToSelector(Selector selector) {
		this.selector = selector;
		if (selector.isShowing())
			setBounds(selector.getLocationOnScreen().x, selector.getLocationOnScreen().y + selector.getHeight() + 2, 
					selector.getWidth() / 3 * 2, selector.getHeight() / 3 * 2 * 4);
	}
	
	public void updateGrid(GridBagLayout layout) {
		gx = layout.getLayoutDimensions()[0][1] % 2;
		gy = layout.getLayoutDimensions()[1][1] % 2;
	}

	public SelectorWindow() {
		super("");
		JPanel mainPanel = new JPanel();
		mainPanel.setBorder(null);
		//mainPanel.setBorder(new EtchedBorder());
		getContentPane().add(mainPanel);
	    setUndecorated(true);
	    setAlwaysOnTop(true);
	    setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
 
	    try {
            if (AWTUtilities.isTranslucencySupported(AWTUtilities.Translucency.TRANSLUCENT))
            {
                //AWTUtilities.setWindowOpacity(this, 0.7f);
            }
        } catch (Exception e) {
            System.out.println("Exception while setting opacity");
        }
        
        mainPanel.setLayout(new GridLayout(4,1,2,2));
        
        for (int i=0;i<4;i++) {
        	
        
        JButton btn1 = new JButton("W"+i);
        //btn1.setPreferredSize(new Dimension(20, 20));
        btn1.setMargin(new Insets(0, 0, 0, 0));
        btn1.setFont(AdaptFontFactory.registerFont(btn1, AdaptFontFactory.SELECTOR));
        
        	mainPanel.add(btn1);
        }
        
        
	}

}
